<?php

require_once ('BaseModel.php');

class RolesInheritance extends BaseModel {
	
	protected $_name = "roles_inheritance";
	protected $_primary = array("role");
	
	public function abstractLoad($id) {
		$stmt = $this->select()->where("role = :_role")->bind(array(":_role"=>$id));
		$row = $this->fetchRow($stmt);
		if ($row == null)	{
			$this->setData($this->createDefaultData());
			return;
		}
		$this->setData($row->toArray());
	}
	
	public function createDefaultData() {
		return array("role"=>"default", "subrole"=>null);
	}
	
	public function getParentRole()	{
		$data = $this->getData();
		return $data['subrole'];
	}
}



?>
